<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ page import="java.util.ArrayList" %>
<%@ page import="hh.g" %>
<%@ page import="hh.m" %>
<jsp:useBean id="myCar" class="hh.s" scope="session"/>
<%
	String action=request.getParameter("action");
	if(action==null){
		action="";
	}
	if(action.equals("buy")){/* 购买商品 */
		ArrayList goodslist=(ArrayList)session.getAttribute("goodslist");
		int id=m.strToint(request.getParameter("id"));
		g single=(g)goodslist.get(id);
		myCar.addItem(single); /* 调用shopcar类中的additem（）方法添加商品 */
		response.sendRedirect("306.jsp");
	}
	else if(action.equals("remove")){	/* 移除商品 */
		String name=request.getParameter("name");/* 获取商品名称 */
		myCar.removerItem(name);/* 调用shopcar类中的removeitem方法移除商品 */
		response.sendRedirect("306s.jsp");
	}
	else if(action.equals("clear")){
		myCar.clearCar(); 			/* 调用shopcar类中的clearcar（）方法清空购物车 */
		response.sendRedirect("306s.jsp");
	}
	else{
		response.sendRedirect("306.jsp");	
	}
 %>

</html>
